<?php
/**
 * Created by PhpStorm.
 * User: 4399-0661
 * Date: 15-5-12
 * Time: 下午6:41
 */

namespace Library\route;


class LibPath extends LibBase
{
    /**
     * /sae/index/info/fds/1/ftt/1
     * 路由算法
     */
    public function action()
    {
        $this->url{0} = "";
        $params = explode("/", $this->url);
        $this->application = $this->filter($params[0], true);
        unset($params[0]);
        if (isset($params[1])) {
            $this->module = $this->filter($params[1], true);
            unset($params[1]);
        } else {
            $this->module = DEFAULT_MODULE;
        }

        if (isset($params[2]) && count($params) % 2 == 1) {
            $this->method = $this->filter($params[2], true);
            unset($params[2]);
        } else {
            $this->method = DEFAULT_METHOD;
        }
        $params = array_values($params);
        if ($params) {
            for ($i = 0; $i < count($params); $i = $i + 2) {
                $_GET[$params[$i]] = $params[$i + 1];
                $_REQUEST[$params[$i]] = $params[$i + 1];
            }
        }
    }

} 